package net.didactylos.helpline.action;

import java.util.List;

import org.hibernate.Session;

import net.didactylos.helpline.data.*;
import net.didactylos.helpline.stripes.bean.HelplineActionBean;
import net.didactylos.helpline.stripes.security.Capabilities;
import net.didactylos.helpline.stripes.security.Secured;
import net.sourceforge.stripes.action.*;

//@UrlBinding("/")
public class HubAction extends HelplineActionBean
{

	private List<Queue> queues;
	
	@SuppressWarnings("unchecked")
	public List<Queue> getQueues()
	{
		if (queues == null)
		{
			Session session = getContext().getSession();
			queues = session.createCriteria(Queue.class).list();
			
			if (queues.size() == 0)
			{
				Queue email = new Queue();
				email.setName("Email");
				session.save(email);
				
				Queue approve = new Queue();
				approve.setName("Check");
				session.save(approve);
				
				queues = session.createCriteria(Queue.class).list();
			}
		}
		return queues;
	}

//	@Before({LifecycleStage.BindingAndValidation})
//	public void preLoad()
//	{
//		
//	}
	
	@DontValidate
	@DefaultHandler
	@Secured(Capabilities.SIGN_IN)
	public Resolution view()
	{
		return new ForwardResolution("index.jspx");
	}
}
